home *** CD-ROM | disk | FTP | other *** search
- {$include:'fink'}
-
- program note(input,output);
- uses filkqq(fcbfqq,filemodes,sequential,terminal,direct);
-
- var
- cmdlin : ads of lstring(128);
- notebook : ads of string(80);
- environ : ads of word;
- cesxqq [extern] : word;
- notefile : text;
- book : lstring(255);
- found,stamp,prompt,switch : boolean;
- dstr,tstr : string(8);
- inline : lstring(255);
- txt_on_line : boolean;
-
- procedure endxqq;extern; { abort }
- procedure date(var dstr:string);extern;
- procedure time(var tstr:string);extern;
-
- procedure find_string; { locates the environment variable NOTEBOOK }
- var
- i,j : integer;
- tmp : string(9);
- begin
- for j := 1 to 9 do
- tmp[j] := notebook^[j];
- if (tmp = 'NOTEBOOK=') then
- begin
- found := true;
- i := 10;
- j := 0;
- while (notebook^[i] <> chr(0)) do
- begin
- j := j + 1;
- book[j] := notebook^[i];
- i := i + 1;
- end;
- book.len := wrd(j);
- end else
- begin
- while (notebook^[1] <> chr(0)) do
- notebook.r := notebook.r + 1;
- notebook.r := notebook.r + 1;
- end;
- end;
-
- procedure give_ins;
- begin
- writeln('Notebook program V1.1 - 1/6/87');
- writeln('Tom Pfau - Digital Equipment Corporation, Parsippany, NJ');
- writeln;
- writeln('This program appends the text of the command line to a');
- writeln('notebook file specified by the NOTEBOOK environment variable.');
- writeln;
- writeln('To use, do the following:');
- writeln(' E>SET NOTEBOOK=E:\TEXT\NOTEBOOK.DAT');
- writeln('Then, to add to the notebook, type:');
- writeln(' E>NOTE This text will be appended to the file');
- writeln;
- writeln('You may optionally timestamp a message or have the program');
- writeln('prompt for the text to be appended.');
- writeln;
- writeln('Command format:');
- writeln(' NOTE [-s] [-p] [text]');
- writeln(' -s Record time of entry');
- writeln(' -p Prompt for text');
- writeln;
- writeln('In prompt mode, multiple lines of text can be entered for a');
- writeln('single note. The note will be delimited by start and end');
- writeln('note markers. If text appears after -p, that text will be');
- writeln('written after the start note marker');
- writeln;
- end;
-
- begin {note}
- found := false;
- stamp := false;
- prompt := false;
- cmdlin.s := cesxqq;
- cmdlin.r := 128;
- while (cmdlin^[1] = ' ') do
- begin
- cmdlin^[1] := chr(cmdlin^.len - 1);
- cmdlin.r := cmdlin.r + 1;
- end;
- txt_on_line := cmdlin^.len <> 0;
- if not(txt_on_line) then
- begin
- give_ins;
- endxqq;
- end;
- switch := false;
- if (cmdlin^[1] = '-') then switch := true;
- while switch do
- begin
- if (cmdlin^[2] = 's') then stamp := true
- else if (cmdlin^[2] = 'p') then prompt := true
- else switch := false;
- if switch then
- begin
- cmdlin^[2] := chr(cmdlin^.len - 2);
- cmdlin.r := cmdlin.r + 2;
- while (cmdlin^[1] = ' ') do
- begin
- cmdlin^[1] := chr(cmdlin^.len - 1);
- cmdlin.r := cmdlin.r + 1;
- end;
- if (cmdlin^[1] <> '-') then switch := false;
- end;
- end;
- txt_on_line := (cmdlin^.len <> 0) or prompt;
- environ.s := cesxqq;
- environ.r := 44;
- notebook.s := environ^;
- notebook.r := 0;
- while (not(found) and (notebook^[1] <> chr(0))) do find_string;
- if not(found) or not(txt_on_line) then
- begin
- give_ins;
- endxqq;
- end;
- assign(notefile,book);
- notefile.trap := true;
- reset(notefile);
- if (notefile.errs <> 0) then
- begin
- notefile.errs := 0;
- rewrite(notefile);
- end else
- while not(eof(notefile)) do readln(notefile);
- notefile.inpt := false;
- date(dstr);
- time(tstr);
- if prompt then
- begin
- write(notefile,'-- start note --');
- if stamp then
- write(notefile,' ',dstr,' ',tstr);
- if (cmdlin^.len <> 0) then
- write(notefile,' | ',cmdlin^);
- writeln(notefile);
- write('Note> ');
- while not(eof(input)) do
- begin
- readln(inline);
- writeln(notefile,inline);
- write('Note> ');
- end;
- writeln(notefile,'-- end note --');
- end else begin
- if stamp then write(notefile,dstr,' ',tstr,' | ');
- writeln(notefile,cmdlin^);
- end;
- end.
-